package com.ems.util;

import java.util.HashMap;
import java.util.Map;

/**
 * 充电桩的帧类型码
 * 充电桩定义的帧类型码为奇数，运营平台定义的帧类型码为偶数；帧类型码分段定义，已定义的帧类型码不可重定义为其他定义
 */
public class StrategyUtil {

    //EMS设备登录请求帧
    public static final String EMS_LOGIN_FRAME_REQUEST = "05";
    //EMS设备连接确认请求帧
    public static final String EMS_CONNECT_QUERY_REQUEST = "10";
    //EMS心跳请求帧
    public static final String EMS_HEAT_FRAME_REQUEST = "06";
    //遥控响应，设备上送
    public static final String EMS_CONTROL_FRAME_REQUEST = "0b";


    static Map<String, String> map = new HashMap<> ();

    /**
     * 根据帧类型选择不同的请求处理器
     * @param type
     * @return
     */
    public static String getKey (String type) {
        if ( map.get ( type ) == null ) {
            map.put ( EMS_LOGIN_FRAME_REQUEST, "loginStrategy" );
        }
        if ( map.get ( type ) == null ) {
            map.put ( EMS_HEAT_FRAME_REQUEST, "heatStrategy" );
        }
        if ( map.get ( type ) == null ) {
            map.put ( EMS_CONNECT_QUERY_REQUEST, "connectStrategy" );
        }
        if ( map.get ( type ) == null ) {
            map.put ( EMS_CONTROL_FRAME_REQUEST, "pcsResponseStrategy" );
        }
        return map.get ( type );
    }

}
